#! /bin/sh
# waveguide - smoothed boundaries between waveguide and media

modelfile=model7.unif           # input model file for unif2aniso
ninf=2                          # number of interfaces (surface counts)
x0=0,0,0                        # x-position(s) for  vp00,vs00,rho00, etc.
z0=0,1000,1100 			# z-position(s) for  vp00,vs00,rho00, etc.
nz=200                          # size of z (depth) dimension  of model
nx=4000                         # size of x (horizontal) dimension of model
dz=10                           # increment in z direction
dx=10                           # increment in x direction
vp00=3320,2898,3320        	# P-wavespeed(s) at (z0,x0)
vs00=1398,950,1398        	# S-wavespeed(s) at (z0,x0)
rho00=2250,2250,2250       	# density(s) at (z0,x0)
eps00=0,0,0	        	# epsilons(s)
delta00=0,0,,0			# delta(s) at (z0,x0)
gamma=0,0,0 	       		 # gammas(s) at (z0,x0)
method=linear			# linear, mono, akima, spline  interpolation
                                #    of boundaries in unif2aniso
dt=0.0005                       # time sampling interval
lt=7.2	                        # latest time modeled
fx=0                            # first x value
verbose=1                       # =1 chatty, =0 silent
snfile="snaps.su"                # output file for snapshots
hsz=1150	                # z-position of horizontal line of geophones
vsx=500		                # x-position of vertical line of geophones
snaptime=.01,.5,1.0,1.5,2.0,2.5,3.0,3.5,4.0,4.5,5.0,5.5,6.0
# times of snapshots
bc=2,10,10,10                   # boundary conditions
qsw=0                           # =1 put in attenuation
asw=0                           # =1 anisotropy
sx=100				# x-position of sources
sz=1150				# z-position of sources
favg=24.15                      # average frequency
ts=.05                          # source duration
wtype=dg                        # waveform type


# build stiffness and density files
unif2aniso < $modelfile ninf=$ninf x0=$x0 z0=$z0 nz=$nz nx=$nx \
dx=$dx dz=$dz vp00=$vp00 vs00=$vs00 rho00=$rho00

xbox=10
ybox=10
nxplot=`bc -l <<-END
        scale=0
        $nx  / 4 
END`
nzplot=`bc -l <<-END
        scale=0
        $nz * 1 
END`

# the files c11_file c13_file c15_file c33_file c35_file c55_file rho_file
# are generated by unif2aniso
# transpose stiffness and density
for i in c11 c13 c15 c33 c35 c55 rho
do
	echo $xbox $ybox
	ximage <  ${i}_file n1=$nz n2=$nx perc=99 xbox=$xbox ybox=$ybox \
	 wbox=$nxplot hbox=$nzplot  legend=1 title=" ${i} parameter file  " &

	xbox=`expr $xbox + 5`
	ybox=`expr $ybox + 110 `
      mv ${i}_file tmp.file
        transp n1=$nz < tmp.file  |
	smooth2 n1=$nz n2=$nx r1=10 r2=10 > ${i}_file
done

rm tmp.file

# run suea2df
suea2df dt=$dt lt=$lt nz=$nz fx=$fx nx=$nx dx=$dx dz=$dz verbose=1 \
snfile=$snfile hsz=$hsz vsx=$vsx snaptime=$snaptime rhofile=rho_file \
bc=$bc qsw=$qsw asw=$asw sx=$sx sz=$sz favg=$favg ts=$ts wtype=$wtype \
>out2


# begin plotting
n2=`bc -l <<-END
      scale=1
       $nx * 2
END`

echo $n2



suxmovie < snaps.su n1=$nz n2=$n2 clip=1e-13 loop=1 title="snapshots horizontal vertical " width=$nxplot height=$nzplot  sleep=200000 &


# shot gathers from a horizontal line of geophones
suximage <  hs.su xbox=0 ybox=400 wbox=$nxplot hbox=$nzplot  perc=99 title="  shot gathers  vertical horizontal " &
suximage <  vsp.su xbox=400 ybox=400  wbox=$nxplot hbox=$nzplot  perc=99 title=" VSP  vertical horizontal " &

exit 0
